package com.buydeem.log;

import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Map;
import java.util.Objects;

/**
 *
 * @author zengchao
 * @date 2022-03-08 11:27:27
 */
public class LogImportSelector implements ImportSelector {

    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        Map<String, Object> map = importingClassMetadata.getAnnotationAttributes(EnableLog.class.getName(), true);
        String value = (String) map.get("value");
        if (Objects.equals(value,"a")){
            return new String[]{LogAServiceImpl.class.getName()};
        }
        return new String[]{LogBServiceImpl.class.getName()};
    }
}
